package collection1;



import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo1 {
    public static void main(String[] args) {
        Collection<Point> c1=new ArrayList<>();
        c1.add(new Point(1,2));
        c1.add(new Point(3,4));
        c1.add(new Point(5,6));
        c1.add(new Point(7,8));
        c1.add(new Point(9,0));
        c1.add(new Point(1,2));
        System.out.println(c1);

        Point p1=new Point(1,2);
        boolean contains1=c1.contains(p1);
        System.out.println(contains1);//true
        //boolean remove(Object o):从当前集合中删除与给定元素o的equals()比较
        //为true的元素，只删除一次
        c1.remove(p1);
        System.out.println(c1);
        c1.remove(p1);
        System.out.println(c1);

        Collection<Point> cc1=new ArrayList<>();
        Point pp1=new Point(1,2);
        cc1.add(pp1);
        System.out.println("pp1:"+pp1);
        System.out.println("cc1:"+cc1);

        pp1.setX(50);
        System.out.println("pp1:"+pp1);
        System.out.println("cc1:"+cc1);


        /*
        Collection<String> c1=new ArrayList<>();
        c1.add("one");
        c1.add("two");
        c1.add("three");
        c1.add("four");
        c1.add("five");
        System.out.println(c1);
        //输出集合的元素个数
        System.out.println(c1.size());//5
        //输出是否为空集
        System.out.println(c1.isEmpty());//false
        //清空集合
        c1.clear();
        System.out.println("集合已清空");
        System.out.println(c1);
        System.out.println(c1.size());//0
        System.out.println(c1.isEmpty());//true

         */











    }
}
